package com.yejiali.backend.controller;

import com.yejiali.backend.entity.dto.CaseAuditDTO;
import com.yejiali.backend.response.Response;
import com.yejiali.backend.service.AuditService;
import io.lettuce.core.dynamic.annotation.Param;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:yejiali
 * @Date:2025/5/17-05-17-13:42
 * @Decsription:com.yejiali.backend.controller
 * @Version:1.0
 */
@RestController
@RequestMapping("/cases")
@Tag(name = "审核管理", description = "审核病例接口")
public class AuditController {
    @Autowired
    private AuditService auditService;

    /**
     * 状态为未审核的病例，分页查询
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/firstCheck")
    @Operation(summary = "查询未初审状态病例", description = "由一级审核员审核未审核病例")
    public Response firstCheck(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize){
        return auditService.firstCheck(pageNum,pageSize);
    }

    /**
     * 状态为已初审的病例，分页查询
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/finalCheck")
    @Operation(summary = "查询已初审病例", description = "对已初审病例进行二审")
    public Response finalCheck(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize){
        return auditService.finalCheck(pageNum,pageSize);
    }

    /**
     * 修改审核状态，初审
     * @return
     */
    @PutMapping ("/updateStatus")
    @Operation(summary = "修改审核状态", description = "修改审核状态")
    public Response updateStatus(@RequestBody CaseAuditDTO caseAuditDTO){
        return auditService.updateStatus(caseAuditDTO);
    }

    /**
     * 根据审核状态查询病例
     * @param status
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/queryCasesByStatus")
    @Operation(summary = "根据审核状态查询病例", description = "根据审核状态查询病例")
    public Response queryCasesByStatus(@RequestParam("status") String status, @RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize){
        return auditService.queryCasesByStatus(status,pageNum,pageSize);
    }

    /**
     * 根据姓名搜索病例
     * @param name
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/searchByName")
    @Operation(summary = "根据姓名搜索病例", description = "根据姓名搜索病例")
    public Response searchByName(@RequestParam("name") String name, @RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize){
        return auditService.searchByName(name,pageNum,pageSize);
    }







}
